home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13035 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question on 'bubble sort'
  5. Date: Thu, 04 Apr 96 00:01:45 GMT
  6. Organization: none
  7. Message-ID: <828576105snz@genesis.demon.co.uk>
  8. References: <4jieso$juc@lantana.singnet.com.sg> <828206958snz@genesis.demon.co.uk> <4jmv0d$t2p@news1.mnsinc.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4jmv0d$t2p@news1.mnsinc.com> huang@mnsinc.com "Szu-Wen Huang" writes:
  15.  
  16. >Lawrence Kirby (fred@genesis.demon.co.uk) wrote:
  17. >: In article <4jieso$juc@lantana.singnet.com.sg>
  18. >:            s8700055@singnet.com.sg "XY Xie" writes:
  19. >
  20. >: >I came across this sorting algorithm called 'bubble sort' in a book.
  21. >
  22. >: If the book doesn't explain why there is never a good reason to use bubble
  23. >: sort then I suggest you get another book.
  24. >
  25. >Sure there is.  If I had 5 minutes to code something that will sort
  26. >10 numbers, bubblesort comes in real handy.  If you've ever joined
  27. >a programming contest you'll know what I mean.
  28.  
  29. I don't want to harp too much on this. However if I was in such a situation I
  30. would write an insertion sort. It is simpler than all but the most naive
  31. bubble sort (and about on a par with that). A proper bubble sort requires
  32. that you note whether any swaps occurred in the inner loop or, better still,
  33. where the last one occurred. Insertion sort is why there is never a good
  34. reason to use (or teach for that matter) bubble sort.
  35.  
  36. -- 
  37. -----------------------------------------
  38. Lawrence Kirby | fred@genesis.demon.co.uk
  39. Wilts, England | 70734.126@compuserve.com
  40. -----------------------------------------
  41.